<?php
Yii::import('application.components.auctionCache.class.AuctionCacheList');
Yii::import('application.components.auctionCache.AuctionCacheData');
class AuctionCategoryList extends AuctionCacheList{
    public $categoryAttribute;
    public $categoryId = 0;
    
    public function listName(){
        return 'category';
    }
    
    public function setCategoryId($categoryId){
        $this->categoryId = $categoryId;
        return $this;
    }
    
    public function cacheKey(){
        return parent::cacheKey().':'.$this->categoryId;
    }

    public function addAuctionItem($auctionCacheData){
        $this->setCategoryId($auctionCacheData->{$this->categoryAttribute})->addItem($auctionCacheData->{$this->scoreAttribute},$auctionCacheData->{$this->indexAttribute});
        return $this;
    }
    
    public function delItem($pk){
        $auction = new AuctionCacheData();
        $auction = $auction->findByPk($pk);        
        $categoryId = $auction->category_id;
        $this->setCategoryId($categoryId);
        return parent::delItem($pk);
    }
    
}
